//+------------------------------------------------------------------+
//|                                                       myMath.mqh |
//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property strict

// 创建箭头
void createArrow(string name, ENUM_OBJECT type, datetime time, double price)
{
    ObjectCreate(0, name, type, 0, time, price);

    if (type == OBJ_ARROW_DOWN) // 看跌
    {
        ObjectSet(name, OBJPROP_COLOR, clrGreen);
        ObjectSetInteger(0, name, OBJPROP_WIDTH, 2);
        ObjectSetInteger(0, name, OBJPROP_BACK, true);
    }
    else // 看涨
    {
        ObjectSet(name, OBJPROP_COLOR, clrRed);
        ObjectSetInteger(0, name, OBJPROP_WIDTH, 2);
        ObjectSetInteger(0, name, OBJPROP_BACK, true);
    }
}

// 删除特定前缀的物件
void deleteObj(string headStr)
{
    int count = ObjectsTotal();
    for (int i = 0; i < count; i++)
    {
        string mName = ObjectName(i);
        string startStr = StringSubstr(mName, 0, StringLen(headStr));

        if (startStr == headStr)
        {
            if (ObjectType(mName) == 22)
            {
                if (!ObjectDelete(mName))
                {
                    Print("物件_" + mName + "_删除失败");
                }
            }
        }
    }
}

// 创建垂直线
void createHLine(string name, ENUM_OBJECT type, datetime time, double price)
{
    ObjectCreate(name, OBJ_VLINE, 0, time, 0);
}